home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / DSOs / forum93 / case8 / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  863 b   |  52 lines

  1. #include <dlfcn.h>
  2. #include <stdio.h>
  3.  
  4.  
  5. main() {
  6.     char choice;
  7.     void *handle;
  8.     void (*msg)(int);
  9.  
  10.     printf("What language would you like your messages in?\n\n");
  11.     printf("   1: English\n\n");
  12.     printf("   2: Spanish\n\n");
  13.     printf("   3: German\n\n");
  14.     printf("   4: French\n\n");
  15.  
  16.     scanf("%c", &choice);
  17.  
  18.     switch (choice) {
  19.     case '1':
  20.     handle = dlopen("english.so", RTLD_LAZY);
  21.     break;
  22.  
  23.     case '2':
  24.     handle = dlopen("spanish.so", RTLD_LAZY);
  25.     break;
  26.  
  27.     case '3':
  28.     handle = dlopen("german.so", RTLD_LAZY);
  29.     break;
  30.  
  31.     case '4':
  32.     handle = dlopen("french.so", RTLD_LAZY);
  33.     break;
  34.  
  35.     }    
  36.  
  37.     if (handle == NULL) {
  38.     fprintf(stderr, "%s\n", dlerror());
  39.     exit(1);
  40.     }
  41.  
  42.     msg =  dlsym(handle, "message");
  43.     if (msg == NULL) {
  44.     fprintf(stderr, "%s\n", dlerror());
  45.     exit(2);
  46.     }
  47.  
  48.     (*msg)(1);
  49.     
  50.     (void) getc(stdin);
  51. }
  52.